package com.soft.link.controller.tsystem;

import com.alibaba.fastjson.JSONObject;
import com.soft.link.controller.BaseController;
import com.soft.link.model.TsMenu;
import com.soft.link.model.TsRole;
import com.soft.link.model.TreeView;
import com.soft.link.service.TsMenuService;
import com.soft.link.service.TsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * company 重庆庆云石油工程技术有限责任公司
 * FileName TsMenuController
 * Package com.soft.link.controller.tsystem
 * Description 菜单显示层
 * author Administrator
 * create 2018-04-09 22:43
 * version V1.0
 */
@Controller
@RequestMapping("system/tsMenu")
public class TsMenuController extends BaseController {

    @Autowired(required = false)
    TsMenuService tsMenuService;

    @Autowired
    TsRoleService tsRoleService;

    // 菜单管理界面
    private  String manageTsMenu = "tsystem/tsmenu/mainTsMenu" ;

    /**
    * @methodname mainTsMenu
    * @Description 菜单管理
    * @author 黄学乾
    * @create 2018/4/9/009 22:44
    * @param  * @param
    * @throws {如果有异常说明请填写}
    * @return
    */
    @RequestMapping("manageTsMenu")
    public ModelAndView manageTsMenu(){
        ModelAndView modelAndView = new ModelAndView(manageTsMenu) ;
        return modelAndView ;
    }

    /**
     * @methodname ajaxMenuTreeViewByTsRole 获取角色菜单树
     * @Description {获取角色菜单树 }
     * @author 黄学乾
     * @create 2018/4/27/027 11:42
     */
    @RequestMapping("ajaxMenuTreeViewByTsRole")
    @ResponseBody
    public List<TreeView> ajaxMenuTreeViewByTsRole(TsRole tsRole) {
        List<TreeView> ztreeViews =  new ArrayList<>() ;
        try {
            List<TsMenu> menuList = tsMenuService.tsMenuService(tsRole);
            ztreeViews = tsMenuService.offSet(menuList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ztreeViews ;
    }

    /**
     * @methodname ajaxMenuTreeViewByTsUser 获取人员菜单树
     * @Description {获取人员菜单树}
     * @author 黄学乾
     * @create 2018/4/27/027 11:46
     */
    @RequestMapping("ajaxMenuTreeViewByTsUser")
    @ResponseBody
    public JSONObject ajaxMenuTreeViewByTsUser() {
        JSONObject obj = new JSONObject();
        return obj;
    }


    /**
     * @param * @param
     * @return
     * @throws {如果有异常说明请填写}
     * @methodname appTreeViewByTsUser 移动终端获取菜单新
     * @Description {移动终端获取人员信息问题}
     * @author 黄学乾
     * @create 2018/4/27/027 11:50
     */
    @RequestMapping("appTreeViewByTsUser")
    @ResponseBody
    public JSONObject appTreeViewByTsUser() {
        JSONObject obj = new JSONObject();
        return obj;
    }


}
